package com.manlitech.manlichat.util.websocketclient;
/**
 * Created by Intellij IDEA.
 * @author:  Shensg
 * Date:  2021/1/22
 */

public class ByteUtils {

    /**
     * byte数组截取
     * @param src 原数据
     * @param begin 开始的index
     * @param count 长度
     * @return
     */
    public static byte[] subBytes(byte[] src, int begin, int count) {
        byte[] bs = new byte[count];
        System.arraycopy(src, begin, bs, 0, count);
        return bs;
    }

    /**
     * 合并bute[]
     * @param bt1
     * @param bt2
     * @return
     */
    public static byte[] byteMerger(byte[] bt1, byte[] bt2){
        byte[] bt3 = new byte[bt1.length+bt2.length];
        int i=0;
        for(byte bt: bt1){
            bt3[i]=bt;
            i++;
        }

        for(byte bt: bt2){
            bt3[i]=bt;
            i++;
        }
        System.out.println("客户端发送数据长度" + bt3.length);
        return bt3;
    }
}

